package com.nuanshui.heatedloan.baseservice.service;

import com.alibaba.dubbo.rpc.RpcContext;
import com.nuanshui.framework.lang.SysStringUtils;
import com.nuanshui.framework.springContext.Environment;
import com.nuanshui.heatedloan.baseservice.facade.BaseService;
import com.nuanshui.heatedloan.baseservice.model.UserAgent;
import com.nuanshui.heatedloan.constant.DubboTransferConstant;
import com.nuanshui.heatedloan.dubbo.DubboResponse;

import javax.servlet.http.HttpServletRequest;

/**
 * 
 * Created by zss on 2017/4/14.
 * 
 */
public class CommonServiceImpl implements BaseService {

	private BaseService baseServiceImpl;

	BaseService getService() {
		if (baseServiceImpl == null) {

			if (Environment.isRestEnv()) {
				baseServiceImpl = new BaseServiceImpl();
			} else {
				baseServiceImpl = new DubboServiceImpl();
			}
		}
		return baseServiceImpl;
	}

	@Override
	public HttpServletRequest getRequest() {
		return getService().getRequest();
	}

	@Override
	public UserAgent getUserAgent() {
		return getService().getUserAgent();
	}

	@Override
	public boolean isFromWechat() {
		return getService().isFromWechat();
	}

	@Override
	public String getWechatOpenId() {
		return getService().getWechatOpenId();
	}

	@Override
	public DubboResponse success(Object object) {
		return getService().success(object);
	}

	@Override
	public void error(String msg) {
		getService().error(msg);
	}

	@Override
	public String getCurrentUserInfo() {
		return getService().getCurrentUserInfo();
	}

	@Override
	public String getCurrentChannel() {
		return getService().getCurrentChannel();
	}

	@Override
	public String getCurrentUserId() {
		return getService().getCurrentUserId();
	}

	@Override
	public String getCurrentOpenId() {
		return getService().getCurrentOpenId();
	}
}
